﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LKL_Code.MotionControlCard
{
    public interface IAxis
    {

        /// <summary>
        /// 轴索引号
        /// </summary>
        int Index { get; }

        /// <summary>
        /// 轴类型
        /// </summary>
        AxisType Type { get; set; }

        /// <summary>
        /// 轴反向
        /// </summary>
        bool Invert { get; set; }

        /// <summary>
        /// 速度
        /// </summary>
        float Speed { get; set; }

        /// <summary>
        /// 加速度
        /// </summary>
        float Accel { get; set; }

        /// <summary>
        /// 减速度
        /// </summary>
        float Decel { get; set; }

        /// <summary>
        /// 脉冲当量
        /// </summary>
        float Unit { get; set; }

        /// <summary>
        /// 相对运动
        /// </summary>
        /// <param name="distance"></param>
        void Move(float distance);

        /// <summary>
        /// 绝对运动
        /// </summary>
        /// <param name="pos"></param>
        void MoveAbs(float pos);

        /// <summary>
        /// 等待轴完成运动
        /// </summary>
        void WaitMoveStop();

        /// <summary>
        /// Jog运动
        /// </summary>
        /// <param name="dir"></param>
        void MoveJog(bool dir, float speedValue);

        /// <summary>
        /// 停止Jog运动（轴运动）
        /// </summary>
        void StopJog();

        /// <summary>
        /// 轴急停
        /// </summary>
        void EmergentStop();

        /// <summary>
        /// 解除急停
        /// </summary>
        void ResetEmergentStop();


        /// <summary>
        /// 轴暂停
        /// </summary>
        void Pause();

        /// <summary>
        /// 暂停恢复
        /// </summary>
        void Resume();

        /// <summary>
        /// 轴状态
        /// </summary>
        AxisStatus Status { get; }

        /// <summary>
        /// 轴位置
        /// </summary>
        float Pos { get; set; }



        /// <summary>
        /// 轴位置
        /// </summary>
        /// <param name="AxisPos"></param>
        void AxisesPos(float[] AxisPos);

        /// <summary>
        /// 轴位置-置零
        /// </summary>
        void AxisesPosZero();



    }


    /// <summary>
    /// 轴类型
    /// </summary>
    public enum AxisType
    {
        /// <summary>
        /// 走脉冲的步进电机或伺服
        /// </summary>
        StepperMotor,
        /// <summary>
        /// EtherCat位置模式
        /// </summary>
        EtherCatPosMotor,
        /// <summary>
        /// EtherCat速度模式
        /// </summary>
        EtherCatSpeedMotor,
        /// <summary>
        /// EtherCat力矩模式
        /// </summary>
        EtherCatTorsionMotor,
    }

    /// <summary>
    /// 轴运动状态
    /// </summary>
    public enum AxisMoveStatus
    {
        /// <summary>
        /// 运动中
        /// </summary>
        Moving,
        /// <summary>
        /// 运动完成
        /// </summary>
        Finish,
        /// <summary>
        /// 异常
        /// </summary>
        GetIndoErr
    }

    /// <summary>
    /// 轴状态
    /// </summary>
    public struct AxisStatus
    {
        /// <summary>
        /// 暂停中
        /// </summary>
        public bool IsPause { get; internal set; }

        /// <summary>
        /// 急停中
        /// </summary>
        public bool IsEmergentStop { get; internal set; }

    }


    /// <summary>
    /// 初始化轴类型
    /// </summary>
    public struct AxisInitType
    {
        public int AxisIndex;
        public AxisType AxisType;

    }
}
